home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-16 | 1.7 KB | 41 lines | [TEXT/GEOL] |
- Item 0178267 14-Feb-90 23:10PST
-
- From: D3632 Cadence Design, Ken Friedenbach,PRT
-
- To: D4695 Skywalker Sys, Scott Collins,PRT
-
- cc: CPLUS.DEV$ C++ Interest List--Developers
-
- Sub: RE-C++ access question
-
- Dear Scott and Neal,
-
- Your "bug?" looks more like a "bug fix!" to me!
-
- The bug (in early versions of 2.0) was that member functions were given
- access to the private members of "this" object, but not to other
- instances of the same class, such as parameters, or locally declared
- variables. This bug may have made "private" seem like "private to an
- object". But in fact, it was always intended to be "private to a class".
-
- Consider the "private loop-hole" or "export" mechanism: the "friend"
- keyword. A "friend" of a class has access to the private members
- of ANY variables of the class: global variables, parameters, or local
- variables. There is no way to say "friend of arg1, but not of arg2",
- or "friend of the args, but not of global variables".
-
- The private/protected/public keywords are intended to support safer
- Software engineering practice, by restricting the scope (or amount of
- text) which can refer to the private members of ANY object of the class.
- They are not intended to support correct design and implementation by
- modifying access to individual objects of a class. (Although that would
- be nice!). The private/protected/public form of protection is better
- than none, but not the ultimate imagineable.
-
- Ken Friedenbach
-
- P.S. Under your interpretation it would make sense to declare a member
- function as a friend of the class, to get access for objects other than
- "this".
-
-